From 671d1e2c93c5f6f0790bc566c0a47c205e08ff9e Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Fri, 30 Mar 2007 18:39:34 +0100 Subject: [PATCH] xen: Fix domain shutdown to synchronously stop domain execution. Signed-off-by: Keir Fraser --- xen/common/domain.c | 6 ++++++ xen/common/domctl.c | 16 +++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index 57d3c5a074..b1f11b75d9 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -265,7 +265,10 @@ void domain_kill(struct domain *d) /* Already dying? Then bail. */ if ( xchg(&d->is_dying, 1) ) + { + domain_unpause(d); return; + } /* Tear down state /after/ setting the dying flag. */ smp_wmb(); @@ -332,8 +335,11 @@ void domain_shutdown(struct domain *d, u8 reason) if ( d->domain_id == 0 ) dom0_shutdown(reason); + atomic_inc(&d->pause_count); if ( !xchg(&d->is_shutdown, 1) ) d->shutdown_code = reason; + else + domain_unpause(d); for_each_vcpu ( d, v ) vcpu_sleep_nosync(v); diff --git a/xen/common/domctl.c b/xen/common/domctl.c index 01af47a008..27fd411363 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -282,17 +282,15 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domctl_t) u_domctl) case XEN_DOMCTL_resumedomain: { struct domain *d = rcu_lock_domain_by_id(op->domain); - struct vcpu *v; ret = -ESRCH; - if ( d != NULL ) - { - ret = 0; - if ( xchg(&d->is_shutdown, 0) ) - for_each_vcpu ( d, v ) - vcpu_wake(v); - rcu_unlock_domain(d); - } + if ( d == NULL ) + break; + + if ( xchg(&d->is_shutdown, 0) ) + domain_unpause(d); + rcu_unlock_domain(d); + ret = 0; } break; -- 2.30.2